package com.baturu.vin.gm.dal.dao;

import com.baturu.vin.gm.dto.GmVinVdsDTO;
import com.baturu.vin.gm.dto.GMVinModelDTO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Created by qindalong on 17/4/20.
 */
public interface VinModelDAO {

    @Insert({"insert into gm_vin_query_result(",
            "vinCode,",
            "catalog,",
            "body,",
            "series,",
            "year,",
            "optionCode,",
            "excludeOptions,",
            "offlineDate,",
            "brand",
            ") values(",
            "#{dto.vinCode},",
            "#{dto.catalog},",
            "#{dto.body},",
            "#{dto.series},",
            "#{dto.year},",
            "#{dto.optionCode},",
            "#{dto.excludeOptions},",
            "#{dto.offlineDate},",
            "#{dto.brand}",
            ")"})
    @Options(useGeneratedKeys = true, keyProperty = "dto.id")
    int insert(@Param("dto") GMVinModelDTO vinModelDTO);


    @Select("select * from gm_vin_query_result where vinCode = #{vinCode}")
    GMVinModelDTO findVinModel(@Param("vinCode") String vinCode);

    @Select({"select distinct btrBrand ,btrSubBrand, carSystem , carType , transmissionDesc,",
            "driveType, engineType , cylinderVolume, fuelType, endSaleDate",
            "from gm_vds_vin",
            "where vinPre8 = #{vinPre8}"})
    List<GmVinVdsDTO> queryVinByVinPre(@Param("vinPre8") String vinPre8);


    @Select({"SELECT description_CN FROM gm_epc_cd_catalogdesc WHERE catalog_code = #{catalog} limit 1"})
    String queryCatalogCh(@Param("catalog") String catalog);

}
